package com.zhaopin.reactor;

import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

/**
 * @author Administrator
 * @create 2019-07-17 18:10
 */
public class ReactorHello {


    @Test
    public void test1(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("test",0);
        Double test = jsonObject.getDouble("test");
        System.out.println(test.intValue());
        StepVerifier.create(generateFluxFrom1To6())
                .expectNext(1, 2, 3, 4, 5, 6)
                .expectComplete()
                .verify();
        StepVerifier.create(generateMonoWithError())
                .expectErrorMessage("some error")
                .verify();
    }
    private Flux<Integer> generateFluxFrom1To6() {
        return Flux.just(1, 2, 3, 4, 5, 6);
    }
    private Mono<Integer> generateMonoWithError() {
        return Mono.error(new Exception("some error"));
    }
}
